package com.bifrost.repository;

import com.bifrost.entity.OrderReturn;
import com.bifrost.entity.OrderReturnItem;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

/**
 * Author by yanxiaobo
 * Date on 2018/6/8$.
 */
public interface OrderReturnItemRepository extends JpaRepository<OrderReturnItem,Long> ,JpaSpecificationExecutor<OrderReturnItem> {

    /**
     * 注意！！！此方法返回的OrderReturnItem实体只包含id、externalId、
     * skuPrice、skuQuantity属性
     * @param orderReturn
     * @return
     */
    @Query("select new OrderReturnItem (o.id,o.externalId,o.skuPrice,o.skuQuantity)from OrderReturnItem o where o.orderReturn =?1")
    List<OrderReturnItem> findByOrderReturn(OrderReturn orderReturn);

    OrderReturnItem findFirstByCouponCode(Long couponCode);
}
